Browse Source

Build: add install/uninstall targets

main
heck 2 years ago
parent
commit
77bc715267
  1. 8
      Makefile
  2. 2
      Makefile.conf
  3. 23
      src/Makefile
  4. 13
      test/Makefile

8
Makefile

@ -10,4 +10,10 @@ test:
clean:
$(MAKE) -C src clean
$(MAKE) -C test clean
$(MAKE) -C test clean
install:
$(MAKE) -C src install
uninstall:
$(MAKE) -C src uninstall

2
Makefile.conf

@ -1,5 +1,5 @@
LIBNAME:=heck_vulkan
LIB:=lib$(LIBNAME).a
LIB_STATIC:=lib$(LIBNAME).a
C_LANG_VERSION=c99
CXX_LANG_VERSION=c++17

23
src/Makefile

@ -1,12 +1,13 @@
include ../Makefile.conf
SRC:=$(wildcard *.c*)
SRC:=$(wildcard *.cc)
SRC_EXE:=$(filter main_%, $(SRC))
SRC_LIB=$(filter-out main_%, $(SRC))
OBJS:=$(addsuffix .o, $(basename $(SRC)))
OBJS_LIB:=$(addsuffix .o, $(basename $(SRC_LIB)))
EXE:=$(basename $(SRC_EXE))
DEPS:=$(addsuffix .d, $(basename $(SRC)))
HEADERS=$(wildcard *.hh *.hxx *.h)
.PHONY: all install uninstall clean
.DEFAULT_GOAL:= all
@ -17,16 +18,26 @@ endif
all: $(EXE)
$(LIB): $(OBJS)
$(LIB_STATIC): $(OBJS)
$(AR) -rc $@ $(OBJS_LIB)
$(EXE) : $(LIB)
$(EXE) : $(LIB_STATIC)
clean:
rm -rf \
$(OBJS) \
$(EXE) \
$(LIB) \
*.d \
$(LIB_STATIC) \
$(DEPS) \
*.dSYM \
*.h.gch
*.h.gch
install: $(LIB_STATIC)
mkdir -p $(PREFIX)/include/heck/
mkdir -p $(PREFIX)/lib
cp -v $(HEADERS) $(PREFIX)/include/heck/
cp -v $(LIB_STATIC) $(PREFIX)/lib/
uninstall:
cd $(PREFIX)/include/heck && rm -vf $(HEADERS)
cd $(PREFIX)/lib && rm -vf $(LIB_STATIC)

13
test/Makefile

@ -3,29 +3,30 @@ include ../Makefile.conf
SRC:=$(wildcard *.c*)
SRC_EXE:=$(filter test_%, $(SRC))
EXE:=$(basename $(SRC_EXE))
DEPS:=$(addsuffix .d, $(basename $(SRC)))
$(info src exe: $(SRC_EXE))
$(info lib: $(LIB))
$(info lib: $(LIB_STATIC))
$(info exe: $(EXE))
LDFLAGS+=-L../src
CFLAGS+=-I../src
CXXFLAGS+=-I../src
.PHONY: lib all clean ../src/$(LIB)
.PHONY: lib all clean ../src/$(LIB_STATIC)
.DEFAULT_GOAL := all
all: $(EXE)
../src/$(LIB):
$(MAKE) -C ../src $(LIB)
../src/$(LIB_STATIC):
$(MAKE) -C ../src $(LIB_STATIC)
$(EXE): ../src/$(LIB)
$(EXE): ../src/$(LIB_STATIC)
clean:
rm -rf \
$(OBJS) \
$(EXE) \
*.d \
$(DEPS) \
*.dSYM \
*.h.gch
Loading…
Cancel
Save