system76-tools

collection of utilities for system76 laptops
git clone https://git.parazyd.org/system76-tools
Log | Files | Refs | README | LICENSE

Makefile (1170B)


      1 .POSIX:
      2 
      3 # Install prefix
      4 PREFIX = /usr/local
      5 
      6 # Common flags
      7 CFLAGS = -std=c99 -pedantic -Wall -Wextra -Werror -Os
      8 LDFLAGS = -s
      9 
     10 # Common headers and objects
     11 HDR = arg.h common.h
     12 OBJ = common.o
     13 
     14 # static suid binaries
     15 SUID_BIN = brightness charge-thresholds perf-profile
     16 BRIGHTNESSOBJ = $(OBJ) brightness.o
     17 CHARGETHRESHOLDSOBJ = $(OBJ) charge-thresholds.o
     18 PERFPROFILEOBJ = $(OBJ) perf-profile.o
     19 
     20 all: $(SUID_BIN)
     21 
     22 $(BRIGHTNESSOBJ) $(CHARGETHRESHOLDSOBJ) $(PERFPROFILEOBJ): $(HDR)
     23 
     24 clean:
     25 	rm -f $(SUID_BIN) $(BRIGHTNESSOBJ) $(CHARGETHRESHOLDSOBJ) $(PERFPROFILEOBJ)
     26 
     27 install: all
     28 	mkdir -p $(DESTDIR)$(PREFIX)/bin
     29 	cp -f $(SUID_BIN) $(DESTDIR)$(PREFIX)/bin
     30 	cd $(DESTDIR)$(PREFIX)/bin && chmod 4711 $(SUID_BIN)
     31 	cd $(DESTDIR)$(PREFIX)/bin && chmod u+s $(SUID_BIN)
     32 
     33 uninstall:
     34 	cd $(DESTDIR)$(PREFIX)/bin && rm -f $(SUID_BIN)
     35 
     36 .SUFFIXES: .c .o
     37 
     38 .c.o:
     39 	$(CC) $(CFLAGS) -c $<
     40 
     41 brightness: $(BRIGHTNESSOBJ)
     42 	$(CC) -o $@ $(BRIGHTNESSOBJ) $(LDFLAGS) -static
     43 
     44 charge-thresholds: $(CHARGETHRESHOLDSOBJ)
     45 	$(CC) -o $@ $(CHARGETHRESHOLDSOBJ) $(LDFLAGS) -static
     46 
     47 perf-profile: $(PERFPROFILEOBJ)
     48 	$(CC) -o $@ $(PERFPROFILEOBJ) $(LDFLAGS) -static
     49 
     50 .PHONY: all clean install uninstall