Merge pull request #115 from bradbishop/refactoring
More skeleton refactoring
diff --git a/Makefile b/Makefile
index 9bbd042..b79675d 100644
--- a/Makefile
+++ b/Makefile
@@ -9,8 +9,7 @@
pwrbutton \
rstbutton
-SUBDIRS = $(GDBUS_APPS) \
- hacks \
+SUBDIRS = hacks \
ledctl \
libopenbmc_intf \
pychassisctl \
@@ -25,19 +24,20 @@
pysystemmgr \
pytools
-REVERSE_SUBDIRS = $(shell echo $(SUBDIRS) | tr ' ' '\n' | tac |tr '\n' ' ')
+REVERSE_SUBDIRS = $(shell echo $(SUBDIRS) $(GDBUS_APPS) | tr ' ' '\n' | tac |tr '\n' ' ')
-.PHONY: subdirs $(SUBDIRS)
+.PHONY: subdirs $(SUBDIRS) $(GDBUS_APPS)
-subdirs: $(SUBDIRS)
+subdirs: $(SUBDIRS) $(GDBUS_APPS)
$(SUBDIRS):
$(MAKE) -C $@
$(GDBUS_APPS): libopenbmc_intf
+ $(MAKE) -C $@ CFLAGS="-I ../$^" LDFLAGS="-L ../$^"
install: subdirs
- @for d in $(SUBDIRS); do \
+ @for d in $(SUBDIRS) $(GDBUS_APPS); do \
$(MAKE) -C $$d $@ DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) || exit 1; \
done
clean:
diff --git a/bmcctl/control_bmc_obj.c b/bmcctl/control_bmc_obj.c
index 6dfa2da..545f780 100644
--- a/bmcctl/control_bmc_obj.c
+++ b/bmcctl/control_bmc_obj.c
@@ -1,8 +1,8 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include "interfaces/openbmc_intf.h"
-#include "openbmc.h"
+#include <openbmc_intf.h>
+#include <openbmc.h>
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/control";
diff --git a/flashbios/flash_bios_obj.c b/flashbios/flash_bios_obj.c
index f865be1..fc42cb4 100644
--- a/flashbios/flash_bios_obj.c
+++ b/flashbios/flash_bios_obj.c
@@ -3,8 +3,8 @@
#include <string.h>
#include <sys/wait.h>
#include <sys/types.h>
-#include "interfaces/openbmc_intf.h"
-#include "openbmc.h"
+#include <openbmc_intf.h>
+#include <openbmc.h>
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/control/flash";
diff --git a/gdbus.mk b/gdbus.mk
index 4b320cb..220a650 100644
--- a/gdbus.mk
+++ b/gdbus.mk
@@ -1,11 +1,5 @@
PACKAGE_DEPS=gio-unix-2.0 glib-2.0
-ALL_CFLAGS+=-iquote ../gdbus -iquote ../libopenbmc_intf
-
-LIBOBMC=$(TOP)/libopenbmc_intf/libopenbmc_intf.so.1
-EXTRA_OBJS+=$(LIBOBMC)
-
-$(LIBOBMC):
- $(MAKE) -C $(TOP)/libopenbmc_intf
+LDLIBS=-lopenbmc_intf
%.o: %_obj.c
$(CC) -c $(ALL_CFLAGS) -o $@ $<
diff --git a/gdbus/codegen b/gdbus/codegen
deleted file mode 100755
index 0fb688e..0000000
--- a/gdbus/codegen
+++ /dev/null
@@ -1 +0,0 @@
-gdbus-codegen --interface-prefix org.openbmc --c-generate-object-manager --generate-c-code interfaces/$1 xml/$1.xml
diff --git a/hostcheckstop/host_checkstop_obj.c b/hostcheckstop/host_checkstop_obj.c
index 0d6d736..74c940e 100644
--- a/hostcheckstop/host_checkstop_obj.c
+++ b/hostcheckstop/host_checkstop_obj.c
@@ -1,6 +1,6 @@
-#include "interfaces/openbmc_intf.h"
-#include "openbmc.h"
-#include "gpio.h"
+#include <openbmc_intf.h>
+#include <openbmc.h>
+#include <gpio.h>
static const gchar* dbus_object_path = "/org/openbmc/control";
static const gchar* object_name = "/org/openbmc/control/checkstop0";
diff --git a/hostwatchdog/host_watchdog_obj.c b/hostwatchdog/host_watchdog_obj.c
index e922dc3..fed29c2 100644
--- a/hostwatchdog/host_watchdog_obj.c
+++ b/hostwatchdog/host_watchdog_obj.c
@@ -1,5 +1,5 @@
-#include "interfaces/openbmc_intf.h"
-#include "openbmc.h"
+#include <openbmc_intf.h>
+#include <openbmc.h>
/* ------------------------------------------------------------------------- */
diff --git a/libopenbmc_intf/Makefile b/libopenbmc_intf/Makefile
index 8853318..cd86906 100644
--- a/libopenbmc_intf/Makefile
+++ b/libopenbmc_intf/Makefile
@@ -1,20 +1,33 @@
+libdir=/usr/lib
+includedir=/usr/include
+
PACKAGE_DEPS=gio-unix-2.0 glib-2.0
-INSTALLDEPS=install-lib
-CLEANDEPS=clean-lib
-DEFAULT_ALL=$(LIBOBMC)
-ALL_CFLAGS+=-iquote ../gdbus
-LIBOBMC=openbmc_intf
+SONAME=libopenbmc_intf.so
+VERSION=1
+LIBOBMC=$(SONAME).$(VERSION)
+INCLUDES=openbmc_intf.h openbmc.h gpio.h
-$(LIBOBMC): %: %.o gpio.o
- $(CC) -shared $(CFLAGS) $(LDFLAGS) -Wl,-soname,lib$(LIBOBMC).so \
- -o lib$@.so.1 $^ $(LDLIBS)
+LDLIBS+=$(shell pkg-config --libs $(PACKAGE_DEPS))
+ALL_CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) -fPIC -Werror $(CFLAGS)
-install-lib:
+all: $(SONAME)
+
+%.o: %.c
+ $(CC) -c $(ALL_CFLAGS) -o $@ $<
+
+$(SONAME): $(LIBOBMC)
+ ln -sf $^ $@
+
+$(LIBOBMC): lib%.so.$(VERSION): %.o gpio.o
+ $(CC) -shared $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(SONAME) \
+ -o $@ $^ $(LDLIBS)
+
+install: $(SONAME) $(LIBOBMC)
+ @mkdir -p $(DESTDIR)$(includedir)
+ install $(INCLUDES) $(DESTDIR)$(includedir)
@mkdir -p $(DESTDIR)$(libdir)
- install lib$(LIBOBMC).so.1 $(DESTDIR)$(libdir)
- ln -s lib$(LIBOBMC).so.1 $(DESTDIR)$(libdir)/lib$(LIBOBMC).so
+ install $(LIBOBMC) $(DESTDIR)$(libdir)
+ ln -sf $(LIBOBMC) $(DESTDIR)$(libdir)/$(SONAME)
-clean-lib:
- rm -f lib$(LIBOBMC).so.1
-
-include ../rules.mk
+clean:
+ rm -f *.o $(LIBOBMC) $(SONAME)
diff --git a/libopenbmc_intf/codegen b/libopenbmc_intf/codegen
new file mode 100755
index 0000000..1c3700d
--- /dev/null
+++ b/libopenbmc_intf/codegen
@@ -0,0 +1 @@
+gdbus-codegen --interface-prefix org.openbmc --c-generate-object-manager --generate-c-code $1 $1.xml
diff --git a/libopenbmc_intf/gpio.c b/libopenbmc_intf/gpio.c
index 25a9df8..9e8164d 100644
--- a/libopenbmc_intf/gpio.c
+++ b/libopenbmc_intf/gpio.c
@@ -7,7 +7,7 @@
#include <argp.h>
#include <sys/stat.h>
#include <sys/mman.h>
-#include "interfaces/openbmc_intf.h"
+#include "openbmc_intf.h"
#include "gpio.h"
diff --git a/libopenbmc_intf/openbmc_intf.c b/libopenbmc_intf/openbmc_intf.c
deleted file mode 120000
index 3ac5de7..0000000
--- a/libopenbmc_intf/openbmc_intf.c
+++ /dev/null
@@ -1 +0,0 @@
-../gdbus/interfaces/openbmc_intf.c
\ No newline at end of file
diff --git a/gdbus/interfaces/openbmc_intf.c b/libopenbmc_intf/openbmc_intf.c
similarity index 99%
rename from gdbus/interfaces/openbmc_intf.c
rename to libopenbmc_intf/openbmc_intf.c
index ff10424..7a15116 100644
--- a/gdbus/interfaces/openbmc_intf.c
+++ b/libopenbmc_intf/openbmc_intf.c
@@ -8,7 +8,7 @@
# include "config.h"
#endif
-#include "interfaces/openbmc_intf.h"
+#include "openbmc_intf.h"
#include <string.h>
#ifdef G_OS_UNIX
diff --git a/libopenbmc_intf/openbmc_intf.h b/libopenbmc_intf/openbmc_intf.h
deleted file mode 120000
index 957c7b7..0000000
--- a/libopenbmc_intf/openbmc_intf.h
+++ /dev/null
@@ -1 +0,0 @@
-../gdbus/interfaces/openbmc_intf.h
\ No newline at end of file
diff --git a/gdbus/interfaces/openbmc_intf.h b/libopenbmc_intf/openbmc_intf.h
similarity index 99%
rename from gdbus/interfaces/openbmc_intf.h
rename to libopenbmc_intf/openbmc_intf.h
index 3ba589d..4a1d7d6 100644
--- a/gdbus/interfaces/openbmc_intf.h
+++ b/libopenbmc_intf/openbmc_intf.h
@@ -4,8 +4,8 @@
* The license of this code is the same as for the source it was derived from.
*/
-#ifndef __INTERFACES_OPENBMC_INTF_H__
-#define __INTERFACES_OPENBMC_INTF_H__
+#ifndef __OPENBMC_INTF_H__
+#define __OPENBMC_INTF_H__
#include <gio/gio.h>
@@ -4197,4 +4197,4 @@
G_END_DECLS
-#endif /* __INTERFACES_OPENBMC_INTF_H__ */
+#endif /* __OPENBMC_INTF_H__ */
diff --git a/gdbus/xml/openbmc_intf.xml b/libopenbmc_intf/openbmc_intf.xml
similarity index 100%
rename from gdbus/xml/openbmc_intf.xml
rename to libopenbmc_intf/openbmc_intf.xml
diff --git a/op-flasher/flasher_obj.c b/op-flasher/flasher_obj.c
index 95892bd..dc14e7d 100644
--- a/op-flasher/flasher_obj.c
+++ b/op-flasher/flasher_obj.c
@@ -20,8 +20,8 @@
#include "io.h"
#include "ast.h"
#include "sfc-ctrl.h"
-#include "interfaces/openbmc_intf.h"
-#include "openbmc.h"
+#include <openbmc_intf.h>
+#include <openbmc.h>
static const gchar* dbus_object_path = "/org/openbmc/control";
static const gchar* dbus_name = "org.openbmc.control.Flasher";
diff --git a/op-hostctl/control_host_obj.c b/op-hostctl/control_host_obj.c
index e65f0af..94b5134 100644
--- a/op-hostctl/control_host_obj.c
+++ b/op-hostctl/control_host_obj.c
@@ -5,9 +5,9 @@
#include <unistd.h>
#include <sys/stat.h>
#include <sys/mman.h>
-#include "interfaces/openbmc_intf.h"
-#include "openbmc.h"
-#include "gpio.h"
+#include <openbmc_intf.h>
+#include <openbmc.h>
+#include <gpio.h>
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/control";
diff --git a/op-pwrctl/power_control_obj.c b/op-pwrctl/power_control_obj.c
index 85a8cff..dfc7fa9 100644
--- a/op-pwrctl/power_control_obj.c
+++ b/op-pwrctl/power_control_obj.c
@@ -7,9 +7,9 @@
#include <sys/stat.h>
#include <sys/mman.h>
#include <syslog.h>
-#include "interfaces/openbmc_intf.h"
-#include "openbmc.h"
-#include "gpio.h"
+#include <openbmc_intf.h>
+#include <openbmc.h>
+#include <gpio.h>
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/control";
diff --git a/pciedetect/pcie_slot_present_obj.c b/pciedetect/pcie_slot_present_obj.c
index 36104e2..a2e7fd8 100644
--- a/pciedetect/pcie_slot_present_obj.c
+++ b/pciedetect/pcie_slot_present_obj.c
@@ -1,9 +1,9 @@
-#include "interfaces/openbmc_intf.h"
-#include "openbmc.h"
+#include <openbmc_intf.h>
+#include <openbmc.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
-#include "gpio.h"
+#include <gpio.h>
#define NUM_SLOTS 8
GPIO slots[NUM_SLOTS] = {
diff --git a/pwrbutton/button_power_obj.c b/pwrbutton/button_power_obj.c
index e093a00..b8bca38 100644
--- a/pwrbutton/button_power_obj.c
+++ b/pwrbutton/button_power_obj.c
@@ -1,7 +1,7 @@
#include <stdio.h>
-#include "interfaces/openbmc_intf.h"
-#include "gpio.h"
-#include "openbmc.h"
+#include <openbmc_intf.h>
+#include <gpio.h>
+#include <openbmc.h>
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/buttons";
diff --git a/rstbutton/button_reset_obj.c b/rstbutton/button_reset_obj.c
index a9321e3..731ecce 100644
--- a/rstbutton/button_reset_obj.c
+++ b/rstbutton/button_reset_obj.c
@@ -1,7 +1,7 @@
#include <stdio.h>
-#include "interfaces/openbmc_intf.h"
-#include "gpio.h"
-#include "openbmc.h"
+#include <openbmc_intf.h>
+#include <gpio.h>
+#include <openbmc.h>
/* ------------------------------------------------------------------------- */
static const gchar* dbus_object_path = "/org/openbmc/buttons";
diff --git a/rules.mk b/rules.mk
index fb6c000..d5d1625 100644
--- a/rules.mk
+++ b/rules.mk
@@ -1,31 +1,24 @@
-TOP := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
-
.DEFAULT_GOAL := all
sbindir=/usr/sbin
-libdir=/usr/lib
LDLIBS+=$(shell pkg-config --libs $(PACKAGE_DEPS))
ALL_CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) -fPIC -Werror $(CFLAGS)
-INSTALLDEPS?=install-bins
BIN_SUFFIX?=.exe
-DEFAULT_ALL?=$(BINS)
-all: $(DEFAULT_ALL)
+all: $(BINS:=$(BIN_SUFFIX))
%.o: %.c
$(CC) -c $(ALL_CFLAGS) -o $@ $<
-$(BINS): %: %.o $(EXTRA_OBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(BIN_SUFFIX) $^ $(LDLIBS)
+$(BINS:=$(BIN_SUFFIX)): %$(BIN_SUFFIX): %.o $(EXTRA_OBJS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
-install-bins: $(BINS)
+install: $(BINS:=$(BIN_SUFFIX))
@mkdir -p $(DESTDIR)$(sbindir)
- @for b in $(BINS); do \
- install $$b$(BIN_SUFFIX) $(DESTDIR)$(sbindir) || exit 1; \
+ @for b in $(BINS:=$(BIN_SUFFIX)); do \
+ install $$b $(DESTDIR)$(sbindir) || exit 1; \
done
-install: all $(INSTALLDEPS)
-
-clean: $(CLEANDEPS)
+clean:
rm -rf *.o $(BINS:=$(BIN_SUFFIX))