# Copyright (C) Zhou Zhongbai 46784314@qq.com
CC = gcc
CFLAGS = -W -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wmissing-prototypes -Winline -Wundef
#CFLAGS += -DBIGENDIAN
#CFLAGS += -DALIGNMENT_WORKAROUND
# When debugging, disable -O2 and enable -g.
CFLAGS += -O2
#CFLAGS += -g
# Pass linker flags here
LDFLAGS =
DESTDIR =
prefix = /usr/local
sbindir = $(prefix)/sbin
mandir = $(prefix)/share/man
man8dir = $(mandir)/man8
docdir = $(prefix)/share/doc/getcpuid
INSTALL := install
INSTALL_DATA := $(INSTALL) -m 644
INSTALL_DIR := $(INSTALL) -m 755 -d
INSTALL_PROGRAM := $(INSTALL) -m 755
RM := rm -f
# BSD make provides $MACHINE, but GNU make doesn't
MACHINE ?= $(shell uname -m 2>/dev/null)
PROGRAMS = getsysinfo
all : $(PROGRAMS)
#
# Programs
#
getsysinfo : getsysinfo.o util.o
$(CC) $(LDFLAGS) getsysinfo.o util.o -o $@
#
# Objects
#
getsysinfo.o : getsysinfo.c util.h
$(CC) $(CFLAGS) -c $< -o $@
util.o : util.c util.h
$(CC) $(CFLAGS) -c $< -o $@
#
# Commands
#
strip : $(PROGRAMS)
strip $(PROGRAMS)
install : install-bin install-man install-doc
uninstall : uninstall-bin uninstall-man uninstall-doc
install-bin : $(PROGRAMS)
$(INSTALL_DIR) $(DESTDIR)$(sbindir)
for program in $(PROGRAMS) ; do \
$(INSTALL_PROGRAM) $$program $(DESTDIR)$(sbindir) ; done
uninstall-bin :
for program in $(PROGRAMS) ; do \
$(RM) $(DESTDIR)$(sbindir)/$$program ; done
install-man :
$(INSTALL_DIR) $(DESTDIR)$(man8dir)
for program in $(PROGRAMS) ; do \
$(INSTALL_DATA) man/$$program.8 $(DESTDIR)$(man8dir) ; done
uninstall-man :
for program in $(PROGRAMS) ; do \
$(RM) $(DESTDIR)$(man8dir)/$$program.8 ; done
install-doc :
$(INSTALL_DIR) $(DESTDIR)$(docdir)
$(INSTALL_DATA) README $(DESTDIR)$(docdir)
$(INSTALL_DATA) CHANGELOG $(DESTDIR)$(docdir)
$(INSTALL_DATA) AUTHORS $(DESTDIR)$(docdir)
uninstall-doc :
$(RM) -r $(DESTDIR)$(docdir)
clean :
$(RM) *.o $(PROGRAMS)