now compiles to static and shared library

error_handling
Avril 4 years ago
parent 3f4c59fa83
commit 32f04d7132
Signed by: flanchan
GPG Key ID: 284488987C31F630

2
.gitignore vendored

@ -1,2 +1,4 @@
cow-* cow-*
*.a
*.so
obj/ obj/

@ -41,10 +41,16 @@ OBJ = $(OBJ_C) $(OBJ_CXX)
# Phonies # Phonies
.PHONY: release .PHONY: release
release: | dirs $(PROJECT)-release release: | dirs $(PROJECT)-release.a
-$(MAKE) clean-rebuild
-$(MAKE) dirs
$(MAKE) $(PROJECT)-release.so
.PHONY: debug .PHONY: debug
debug: | dirs $(PROJECT)-debug debug: | dirs $(PROJECT)-debug.a
-$(MAKE) clean-rebuild
-$(MAKE) dirs
$(MAKE) $(PROJECT)-debug.so
# Targets # Targets
@ -57,22 +63,36 @@ obj/c/%.o: %.c
obj/cxx/%.o: %.cpp obj/cxx/%.o: %.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@ $(LDFLAGS) $(CXX) -c $< $(CXXFLAGS) -o $@ $(LDFLAGS)
$(PROJECT)-release: CFLAGS+= $(RELEASE_CFLAGS) $(PROJECT)-release.a: CFLAGS+= $(RELEASE_CFLAGS)
$(PROJECT)-release: CXXFLAGS += $(RELEASE_CXXFLAGS) $(PROJECT)-release.a: CXXFLAGS += $(RELEASE_CXXFLAGS)
$(PROJECT)-release: LDFLAGS += $(RELEASE_LDFLAGS) $(PROJECT)-release.a: LDFLAGS += $(RELEASE_LDFLAGS)
$(PROJECT)-release: $(OBJ) $(PROJECT)-release.a: $(OBJ)
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS) ar rcs $@ $^
ln -sf $@ $(PROJECT).a
$(PROJECT)-debug.a: CFLAGS+= $(DEBUG_CFLAGS)
$(PROJECT)-debug.a: CXXFLAGS += $(DEBUG_CXXFLAGS)
$(PROJECT)-debug.a: LDFLAGS += $(DEBUG_LDFLAGS)
$(PROJECT)-debug.a: $(OBJ)
ar rcs $@ $^
$(PROJECT)-release.so: CFLAGS+= $(RELEASE_CFLAGS) -fPIC
$(PROJECT)-release.so: CXXFLAGS += $(RELEASE_CXXFLAGS) -fPIC
$(PROJECT)-release.so: LDFLAGS += $(RELEASE_LDFLAGS)
$(PROJECT)-release.so: $(OBJ)
$(CXX) -shared $^ -o $@
$(STRIP) $@ $(STRIP) $@
ln -sf $@ $(PROJECT).so
$(PROJECT)-debug: CFLAGS+= $(DEBUG_CFLAGS) $(PROJECT)-debug.so: CFLAGS+= $(DEBUG_CFLAGS) -fPIC
$(PROJECT)-debug: CXXFLAGS += $(DEBUG_CXXFLAGS) $(PROJECT)-debug.so: CXXFLAGS += $(DEBUG_CXXFLAGS) -fPIC
$(PROJECT)-debug: LDFLAGS += $(DEBUG_LDFLAGS) $(PROJECT)-debug.so: LDFLAGS += $(DEBUG_LDFLAGS)
$(PROJECT)-debug: $(OBJ) $(PROJECT)-debug.so: $(OBJ)
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS) $(CXX) -shared $^ -o $@
clean-rebuild: clean-rebuild:
rm -rf obj rm -rf obj
clean: clean-rebuild clean: clean-rebuild
rm -f $(PROJECT)-{release,debug,pgo} rm -f $(PROJECT){,-{release,debug,pgo}}.{a,so}

Loading…
Cancel
Save