Browse Source

Output libraries in bin/.

scossu 1 year ago
parent
commit
d3cf9698d3
1 changed files with 15 additions and 11 deletions
  1. 15 11
      Makefile

+ 15 - 11
Makefile

@@ -13,6 +13,7 @@ PREFIX ?= /usr/local
 bindir = $(PREFIX)/bin
 libdir = $(PREFIX)/lib
 includedir = $(PREFIX)/include/lsup
+outdir = ./bin
 
 INCLUDE = -I. -Iinclude -I$(includedir)
 # Link all ext libraries statically.
@@ -27,8 +28,12 @@ DBG_OBJ = $(SRC:.c=_dbg.o)
 
 TEST_SRC = $(wildcard test/*.c) test.c
 
-LIBS = liblsuprepo.a liblsuprepo.so
-DBG_LIBS = liblsuprepo_dbg.a liblsuprepo_dbg.so
+STATIC_LIB = $(outdir)/liblsuprepo.a
+DYN_LIB = $(outdir)/liblsuprepo.so
+STATIC_DBG_LIB = $(outdir)/liblsuprepo_dbg.a
+DYN_DBG_LIB = $(outdir)/liblsuprepo_dbg.so
+LIBS = $(STATIC_LIB) $(DYN_LIB)
+DBG_LIBS = $(STATIC_DBG_LIB) $(DYN_DBG_LIB)
 
 
 ## Environment.
@@ -56,19 +61,19 @@ lib: $(LIBS)
 debug: $(DBG_LIBS)
 
 
-liblsuprepo.a: $(OBJ)
+$(STATIC_LIB): $(OBJ)
 	$(AR) rs $@ $^
 
 
-liblsuprepo.so: $(OBJ)
+$(DYN_LIB): $(OBJ)
 	$(CC) -shared $(LDFLAGS) -o $@ $^
 
 
-liblsuprepo_dbg.a: $(DBG_OBJ)
+$(STATIC_DBG_LIB): $(DBG_OBJ)
 	$(AR) rs $@ $^
 
 
-liblsuprepo_dbg.so: $(DBG_OBJ)
+$(DYN_DBG_LIB): $(DBG_OBJ)
 	$(CC) -shared $(LDFLAGS) -o $@ $^
 
 
@@ -80,19 +85,18 @@ liblsuprepo_dbg.so: $(DBG_OBJ)
 install: lib ## Install default libraries to $PREFIX. May require sudo.
 	mkdir -p $(DESTDIR)$(libdir)
 	mkdir -p $(DESTDIR)$(includedir)
-	cp liblsuprepo.* $(DESTDIR)$(libdir) && \
+	cp $(LIBS) $(DESTDIR)$(libdir) && \
 		cp include/*.h $(EXT_H) $(DESTDIR)$(includedir)
 
 
 debug_install: install debug ## Install default and debug libraries.
-	cp liblsuprdf_dbg.{a,so} $(DESTDIR)$(libdir)
-	
+	cp $(DBG_LIBS) $(DESTDIR)$(libdir)
 
 
 .PHONY: clean
 clean:
-	rm -rf src/*.[aod] ./*.{a,o,d,so}
-	rm -f bin/test*
+	rm -rf src/*.[aod]
+	rm -f $(LIBS) bin/test*
 
 
 .PHONY: uninstall