smdev

suckless mdev
git clone git://git.2f30.org/smdev
Log | Files | Refs | README | LICENSE

Makefile (1133B)


      1 include config.mk
      2 
      3 .POSIX:
      4 .SUFFIXES: .c .o
      5 
      6 LIB = \
      7 	util/agetcwd.o      \
      8 	util/apathmax.o     \
      9 	util/dev.o          \
     10 	util/eprintf.o      \
     11 	util/estrtol.o      \
     12 	util/mkpath.o       \
     13 	util/recurse.o      \
     14 	util/strlcpy.o
     15 
     16 SRC = smdev.c
     17 
     18 OBJ = $(SRC:.c=.o) $(LIB)
     19 BIN = $(SRC:.c=)
     20 MAN = $(SRC:.c=.1)
     21 
     22 all: options binlib
     23 
     24 options:
     25 	@echo mdev build options:
     26 	@echo "CFLAGS   = $(CFLAGS)"
     27 	@echo "LDFLAGS  = $(LDFLAGS)"
     28 	@echo "CC       = $(CC)"
     29 
     30 binlib: util.a
     31 	$(MAKE) bin
     32 
     33 bin: $(BIN)
     34 
     35 $(OBJ): config.h util.h config.mk
     36 
     37 config.h:
     38 	@echo creating $@ from config.def.h
     39 	@cp config.def.h $@
     40 
     41 .o:
     42 	@echo LD $@
     43 	@$(LD) -o $@ $< util.a $(LDFLAGS)
     44 
     45 .c.o:
     46 	@echo CC $<
     47 	@$(CC) -c -o $@ $< $(CFLAGS)
     48 
     49 util.a: $(LIB)
     50 	@echo AR $@
     51 	@$(AR) -r -c $@ $(LIB)
     52 	@ranlib $@
     53 
     54 install: all
     55 	@echo installing executable to $(DESTDIR)$(PREFIX)/bin
     56 	@mkdir -p $(DESTDIR)$(PREFIX)/bin
     57 	@cp -f $(BIN) $(DESTDIR)$(PREFIX)/bin
     58 	@cd $(DESTDIR)$(PREFIX)/bin && chmod 755 $(BIN)
     59 
     60 uninstall:
     61 	@echo removing executable from $(DESTDIR)$(PREFIX)/bin
     62 	@cd $(DESTDIR)$(PREFIX)/bin && rm -f $(BIN)
     63 
     64 clean:
     65 	@echo cleaning
     66 	@rm -f $(BIN) $(OBJ) $(LIB) util.a