diff options
author | Christian Hesse <mail@eworm.de> | 2017-05-13 22:07:02 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2017-05-13 22:08:04 +0200 |
commit | 38a079064afe1b2e55911e4c23ac8a76e2cf24be (patch) | |
tree | 05ca0588a2f97e5d948d497d41a2f49d0fda6477 | |
parent | f43e14906743c2940487494ad3f9925408e78cba (diff) | |
download | pacredir-38a079064afe1b2e55911e4c23ac8a76e2cf24be.tar.gz pacredir-38a079064afe1b2e55911e4c23ac8a76e2cf24be.tar.zst |
use a smarter way to determine architecture
-rw-r--r-- | Makefile | 16 | ||||
-rw-r--r-- | arch.c | 21 | ||||
-rw-r--r-- | arch.h | 30 | ||||
-rw-r--r-- | pacredir.h | 1 |
4 files changed, 7 insertions, 61 deletions
@@ -23,6 +23,7 @@ CFLAGS_EXTRA += -liniparser LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie # the distribution ID +ARCH := $(shell shopt -u extglob && source /etc/makepkg.conf && echo $$CARCH) ID := $(shell grep 'ID=' < /etc/os-release | cut -d= -f2) # this is just a fallback in case you do not use git but downloaded @@ -31,11 +32,8 @@ VERSION := 0.2.2 all: pacredir avahi/pacdbserve.service avahi/pacserve.service README.html -arch: arch.c arch.h - $(CC) $(CFLAGS) $(LDFLAGS) -o arch arch.c - -pacredir: pacredir.c arch.h pacredir.h config.h version.h - $(CC) $(CFLAGS) $(CFLAGS_EXTRA) $(LDFLAGS) -DREPRODUCIBLE=$(REPRODUCIBLE) -DID=\"$(ID)\" -o pacredir pacredir.c +pacredir: pacredir.c pacredir.h config.h version.h + $(CC) $(CFLAGS) $(CFLAGS_EXTRA) $(LDFLAGS) -DREPRODUCIBLE=$(REPRODUCIBLE) -DARCH=\"$(ARCH)\" -DID=\"$(ID)\" -o pacredir pacredir.c config.h: $(CP) config.def.h config.h @@ -45,8 +43,8 @@ version.h: $(wildcard .git/HEAD .git/index .git/refs/tags/*) Makefile echo "#define VERSION \"$(shell git describe --tags --long 2>/dev/null || echo ${VERSION})\"" >> $@ echo "#endif" >> $@ -avahi/pacdbserve.service: arch avahi/pacdbserve.service.in - $(SED) 's/%ARCH%/$(shell ./arch)/;s/%ID%/$(ID)/' avahi/pacdbserve.service.in > avahi/pacdbserve.service +avahi/pacdbserve.service: avahi/pacdbserve.service.in + $(SED) 's/%ARCH%/$(ARCH)/;s/%ID%/$(ID)/' avahi/pacdbserve.service.in > avahi/pacdbserve.service avahi/pacserve.service: avahi/pacserve.service.in $(SED) 's/%ID%/$(ID)/' avahi/pacserve.service.in > avahi/pacserve.service @@ -77,10 +75,10 @@ install-doc: README.html $(INSTALL) -D -m0644 README.html $(DESTDIR)$(PREFIX)/share/doc/pacredir/README.html clean: - $(RM) -f *.o *~ arch pacredir avahi/pacdbserve.service avahi/pacserve.service README.html version.h + $(RM) -f *.o *~ pacredir avahi/pacdbserve.service avahi/pacserve.service README.html version.h distclean: - $(RM) -f *.o *~ arch pacredir avahi/pacdbserve.service avahi/pacserve.service README.html version.h config.h + $(RM) -f *.o *~ pacredir avahi/pacdbserve.service avahi/pacserve.service README.html version.h config.h release: git archive --format=tar.xz --prefix=pacredir-$(VERSION)/ $(VERSION) > pacredir-$(VERSION).tar.xz @@ -1,21 +0,0 @@ -/* - * (C) 2013-2017 by Christian Hesse <mail@eworm.de> - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - */ - -#include <stdio.h> -#include <stdlib.h> - -#include "arch.h" - -/*** main ***/ -int main(int argc, char ** argv) { - /* just print the architecture */ - puts(ARCH); - - return EXIT_SUCCESS; -} - -// vim: set syntax=c: @@ -1,30 +0,0 @@ -/* - * (C) 2013-2017 by Christian Hesse <mail@eworm.de> - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - */ - -#ifndef _ARCH_H -#define _ARCH_H - -/* the binary needs to know its own architecture */ -#if defined __x86_64__ -# define ARCH "x86_64" -#elif defined __i386__ -# define ARCH "i686" -#elif defined __ARM_ARCH_7__ -# define ARCH "armv7h" -#elif defined __ARM_ARCH_6__ -# if defined __VFP_FP__ -# define ARCH "armv6h" -# else -# define ARCH "arm" -# endif -#else -# error Unknown architecture! -#endif - -#endif /* _ARCH_H */ - -// vim: set syntax=c: @@ -39,7 +39,6 @@ #include <pthread.h> /* compile time configuration */ -#include "arch.h" #include "config.h" #include "version.h" |