Merge pull request #101 from bradbishop/refactoring
skeleton refactoring
diff --git a/.gitignore b/.gitignore
index 28e70be..a76f2a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
-lib/*
-obj/*
-bin/*.exe
-bin/pflash
+*.exe
+*.o
+*.so
+*.so.*
*.swp
*.swo
+*/build
diff --git a/Makefile b/Makefile
old mode 100755
new mode 100644
index 7129082..87acb71
--- a/Makefile
+++ b/Makefile
@@ -1,77 +1,50 @@
-#CC=gcc
-OBJS = objects/pflash/progress.o objects/pflash/ast-sf-ctrl.o
-OBJS += objects/pflash/libflash/libflash.o objects/pflash/libflash/libffs.o
-OBJS += objects/pflash/arm_io.o
-OBJS2 = progress.o ast-sf-ctrl.o libflash.o libffs.o arm_io.o
-OBJS3 = obj/progress.o obj/ast-sf-ctrl.o obj/libflash.o obj/libffs.o obj/arm_io.o
-INCLUDES=$(shell pkg-config --cflags gio-unix-2.0 glib-2.0) -Iincludes -Iobjects/pflash -I.
-LIBS=$(shell pkg-config --libs gio-unix-2.0 glib-2.0) -Llib -lopenbmc_intf
-INCLUDES += $(shell pkg-config --cflags --libs libsystemd) -I. -O2
-LIB_FLAG += $(shell pkg-config --libs libsystemd)
+GDBUS_APPS = bmcctl \
+ bmcctl-barreleye \
+ boardvpd \
+ fanctl \
+ flashbios \
+ hostwatchdog \
+ hwmon \
+ hwmon-barreleye \
+ op-flasher \
+ op-hostctl \
+ op-pwrctl \
+ pciedetect \
+ pwrbutton \
+ rstbutton
-%.o: interfaces/%.c
- $(CC) -c -fPIC -o obj/$@ $< $(CFLAGS) $(INCLUDES)
+SUBDIRS = $(GDBUS_APPS) \
+ hacks \
+ ledctl \
+ libopenbmc_intf \
+ pychassisctl \
+ pydownloadmgr \
+ pyfanctl \
+ pyflashbmc \
+ pyhwmon \
+ pyinventorymgr \
+ pyipmitest \
+ pysensormgr \
+ pystatemgr \
+ pysystemmgr \
+ pytools
-%.o: objects/%.c
- $(CC) -c -o obj/$@ $< $(LIBS) $(CFLAGS) $(INCLUDES)
+REVERSE_SUBDIRS = $(shell echo $(SUBDIRS) | tr ' ' '\n' | tac |tr '\n' ' ')
-%.o: includes/%.c
- $(CC) -c -o obj/$@ $< $(LIBS) $(CFLAGS) $(INCLUDES)
+.PHONY: subdirs $(SUBDIRS)
-%.o: objects/pflash/%.c
- $(CC) -c -o obj/$@ $< $(CFLAGS) $(INCLUDES)
+subdirs: $(SUBDIRS)
-%.o: objects/pflash/libflash/%.c
- $(CC) -c -o obj/$@ $< $(CFLAGS) $(INCLUDES)
+$(SUBDIRS):
+ $(MAKE) -C $@
-all: setup libopenbmc_intf power_control led_controller button_power button_reset control_host host_watchdog board_vpd pcie_slot_present flash_bios flasher pflash hwmons_barreleye control_bmc
+$(GDBUS_APPS): libopenbmc_intf
-setup:
- mkdir -p obj lib
-
-clean:
- rm -rf obj lib bin/*.exe
-
-libopenbmc_intf: openbmc_intf.o
- $(CC) -shared -o lib/$@.so obj/openbmc_intf.o $(LDFLAGS)
-
-power_control: power_control_obj.o gpio.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/gpio.o obj/power_control_obj.o $(LDFLAGS) $(LIBS)
-
-led_controller: led_controller.o
- $(CC) -o bin/$@.exe obj/led_controller.o $(LDFLAGS) $(LIB_FLAG)
-
-button_power: button_power_obj.o gpio.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/button_power_obj.o obj/gpio.o $(LDFLAGS) $(LIBS)
-
-button_reset: button_reset_obj.o gpio.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/button_reset_obj.o obj/gpio.o $(LDFLAGS) $(LIBS)
-
-
-control_host: control_host_obj.o gpio.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/gpio.o obj/control_host_obj.o $(LDFLAGS) $(LIBS)
-
-flash_bios: flash_bios_obj.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/flash_bios_obj.o $(LDFLAGS) $(LIBS)
-
-host_watchdog: host_watchdog_obj.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/host_watchdog_obj.o $(LDFLAGS) $(LIBS)
-
-board_vpd: board_vpd_obj.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/board_vpd_obj.o $(LDFLAGS) $(LIBS)
-
-pcie_slot_present: pcie_slot_present_obj.o gpio.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/pcie_slot_present_obj.o obj/gpio.o $(LDFLAGS) $(LIBS)
-
-flasher: $(OBJS2) flasher_obj.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/flasher_obj.o $(OBJS3) $(LDFLAGS) $(LIBS)
-
-pflash: $(OBJS2) pflash.o
- $(CC) -o bin/$@ obj/pflash.o $(OBJS3) $(LDFLAGS)
-
-hwmons_barreleye: hwmons_barreleye.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/hwmons_barreleye.o $(LDFLAGS) $(LIBS)
-
-control_bmc: control_bmc_obj.o libopenbmc_intf
- $(CC) -o bin/$@.exe obj/control_bmc_obj.o $(LDFLAGS) $(LIBS)
-
+install: subdirs
+ @for d in $(SUBDIRS); do \
+ $(MAKE) -C $$d $@ DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) || exit 1; \
+ done
+clean:
+ @for d in $(REVERSE_SUBDIRS); do \
+ $(MAKE) -C $$d $@ || exit 1; \
+ done
diff --git a/Makefile.python b/Makefile.python
new file mode 100644
index 0000000..e501457
--- /dev/null
+++ b/Makefile.python
@@ -0,0 +1 @@
+include ../py.mk
diff --git a/bin/hconsole b/bin/hconsole
deleted file mode 100755
index 0d2777c..0000000
--- a/bin/hconsole
+++ /dev/null
@@ -1,13 +0,0 @@
-#! /bin/sh
-
-echo "Ctrl-a k to exit console"
-echo "A session log is created in current directory"
-if screen -list | grep "hostconsole" | grep -q -i "Detached"; then
- echo "You have an existing detached console session to host, you will be reconnected to that session"
-fi
-if screen -list | grep "hostconsole" | grep -q -i "Attached"; then
- echo "You have an existing attached console session to host, you will be detached from that session and reconnected here instead"
-fi
-echo "[Enter] to continue"
-read a
-screen -dR hostconsole -U /dev/ttyS5
diff --git a/bmcctl-barreleye/Makefile b/bmcctl-barreleye/Makefile
new file mode 100644
index 0000000..d98fdeb
--- /dev/null
+++ b/bmcctl-barreleye/Makefile
@@ -0,0 +1,3 @@
+BINS=control_bmc_barreleye
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/control_bmc_barreleye.c b/bmcctl-barreleye/control_bmc_barreleye.c
similarity index 100%
rename from objects/control_bmc_barreleye.c
rename to bmcctl-barreleye/control_bmc_barreleye.c
diff --git a/bmcctl/Makefile b/bmcctl/Makefile
new file mode 100644
index 0000000..5d46ab0
--- /dev/null
+++ b/bmcctl/Makefile
@@ -0,0 +1,3 @@
+BINS=control_bmc
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/control_bmc_obj.c b/bmcctl/control_bmc_obj.c
similarity index 100%
rename from objects/control_bmc_obj.c
rename to bmcctl/control_bmc_obj.c
diff --git a/boardvpd/Makefile b/boardvpd/Makefile
new file mode 100644
index 0000000..e19c0db
--- /dev/null
+++ b/boardvpd/Makefile
@@ -0,0 +1,3 @@
+BINS=board_vpd
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/board_vpd_obj.c b/boardvpd/board_vpd_obj.c
similarity index 100%
rename from objects/board_vpd_obj.c
rename to boardvpd/board_vpd_obj.c
diff --git a/bin/Barreleye.py b/configs/Barreleye.py
old mode 100755
new mode 100644
similarity index 100%
rename from bin/Barreleye.py
rename to configs/Barreleye.py
diff --git a/bin/Firestone.py b/configs/Firestone.py
old mode 100755
new mode 100644
similarity index 100%
rename from bin/Firestone.py
rename to configs/Firestone.py
diff --git a/bin/Garrison.py b/configs/Garrison.py
old mode 100755
new mode 100644
similarity index 100%
rename from bin/Garrison.py
rename to configs/Garrison.py
diff --git a/bin/Palmetto.py b/configs/Palmetto.py
old mode 100755
new mode 100644
similarity index 100%
rename from bin/Palmetto.py
rename to configs/Palmetto.py
diff --git a/fanctl/Makefile b/fanctl/Makefile
new file mode 100644
index 0000000..4f86828
--- /dev/null
+++ b/fanctl/Makefile
@@ -0,0 +1,3 @@
+BINS=fan_generic
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/fan_generic_obj.c b/fanctl/fan_generic_obj.c
similarity index 100%
rename from objects/fan_generic_obj.c
rename to fanctl/fan_generic_obj.c
diff --git a/flashbios/Makefile b/flashbios/Makefile
new file mode 100644
index 0000000..4fdb4af
--- /dev/null
+++ b/flashbios/Makefile
@@ -0,0 +1,3 @@
+BINS=flash_bios
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/flash_bios_obj.c b/flashbios/flash_bios_obj.c
similarity index 100%
rename from objects/flash_bios_obj.c
rename to flashbios/flash_bios_obj.c
diff --git a/gdbus.mk b/gdbus.mk
new file mode 100644
index 0000000..dcbf6c9
--- /dev/null
+++ b/gdbus.mk
@@ -0,0 +1,11 @@
+PACKAGE_DEPS=gio-unix-2.0 glib-2.0
+CFLAGS+=-iquote ../gdbus -iquote ../libopenbmc_intf
+
+LIBOBMC=$(TOP)/libopenbmc_intf/libopenbmc_intf.so.1
+EXTRA_OBJS+=$(LIBOBMC)
+
+$(LIBOBMC):
+ $(MAKE) -C $(TOP)/libopenbmc_intf
+
+%.o: %_obj.c
+ $(CC) -c $(CFLAGS) -fPIC -o $@ $<
diff --git a/codegen b/gdbus/codegen
similarity index 100%
rename from codegen
rename to gdbus/codegen
diff --git a/interfaces/openbmc_intf.c b/gdbus/interfaces/openbmc_intf.c
similarity index 100%
rename from interfaces/openbmc_intf.c
rename to gdbus/interfaces/openbmc_intf.c
diff --git a/interfaces/openbmc_intf.h b/gdbus/interfaces/openbmc_intf.h
similarity index 100%
rename from interfaces/openbmc_intf.h
rename to gdbus/interfaces/openbmc_intf.h
diff --git a/xml/openbmc_intf.xml b/gdbus/xml/openbmc_intf.xml
similarity index 100%
rename from xml/openbmc_intf.xml
rename to gdbus/xml/openbmc_intf.xml
diff --git a/hacks/Makefile b/hacks/Makefile
new file mode 100644
index 0000000..abb4ed3
--- /dev/null
+++ b/hacks/Makefile
@@ -0,0 +1,7 @@
+all:
+
+install:
+ mkdir -p $(DESTDIR)/usr/sbin
+ install startup_hacks.sh $(DESTDIR)/usr/sbin
+
+clean:
diff --git a/bin/startup_hacks.sh b/hacks/startup_hacks.sh
old mode 100755
new mode 100644
similarity index 100%
rename from bin/startup_hacks.sh
rename to hacks/startup_hacks.sh
diff --git a/hostwatchdog/Makefile b/hostwatchdog/Makefile
new file mode 100644
index 0000000..d4d2ed3
--- /dev/null
+++ b/hostwatchdog/Makefile
@@ -0,0 +1,3 @@
+BINS=host_watchdog
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/host_watchdog_obj.c b/hostwatchdog/host_watchdog_obj.c
similarity index 100%
rename from objects/host_watchdog_obj.c
rename to hostwatchdog/host_watchdog_obj.c
diff --git a/hwmon-barreleye/Makefile b/hwmon-barreleye/Makefile
new file mode 100644
index 0000000..4e89e3c
--- /dev/null
+++ b/hwmon-barreleye/Makefile
@@ -0,0 +1,3 @@
+BINS=hwmons_barreleye
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/hwmons_barreleye.c b/hwmon-barreleye/hwmons_barreleye.c
similarity index 100%
rename from objects/hwmons_barreleye.c
rename to hwmon-barreleye/hwmons_barreleye.c
diff --git a/hwmon/Makefile b/hwmon/Makefile
new file mode 100644
index 0000000..5b9a70f
--- /dev/null
+++ b/hwmon/Makefile
@@ -0,0 +1,3 @@
+BINS=hwmons_palmetto
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/hwmons_palmetto.c b/hwmon/hwmons_palmetto.c
similarity index 100%
rename from objects/hwmons_palmetto.c
rename to hwmon/hwmons_palmetto.c
diff --git a/includes/sensor_threshold.c b/includes/sensor_threshold.c
deleted file mode 100644
index adf8f5e..0000000
--- a/includes/sensor_threshold.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <argp.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-
-#include "sensor_threshold.h"
-#include "openbmc.h"
-
-gboolean
-get_threshold_state (SensorThreshold *sen,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- guint state = sensor_threshold_get_state(sen);
- sensor_threshold_complete_get_state(sen,invocation,state);
- return TRUE;
-}
-
-
-
-void check_thresholds(SensorThreshold* sensor,GVariant* value)
-{
- threshold_states current_state = sensor_threshold_get_state(sensor);
- //if (current_state != NOT_SET)
- //{
- threshold_states state = NORMAL;
- if (VARIANT_COMPARE(value,sensor_threshold_get_lower_critical(sensor)) < 0) {
- state = LOWER_CRITICAL;
- }
- else if(VARIANT_COMPARE(value,sensor_threshold_get_lower_warning(sensor)) < 0) {
- state = LOWER_WARNING;
- }
- else if(VARIANT_COMPARE(value,sensor_threshold_get_upper_critical(sensor)) > 0) {
- state = UPPER_CRITICAL;
- }
- else if(VARIANT_COMPARE(value,sensor_threshold_get_upper_warning(sensor)) > 0) {
- state = UPPER_WARNING;
- }
- // only emit signal if threshold state changes
- if (state != sensor_threshold_get_state(sensor))
- {
- sensor_threshold_set_state(sensor,state);
- if (state == LOWER_CRITICAL || state == UPPER_CRITICAL)
- {
- sensor_threshold_emit_critical(sensor);
- }
- else if (state == LOWER_WARNING || state == UPPER_WARNING)
- {
- sensor_threshold_emit_warning(sensor);
- }
- else if (state == NORMAL)
- {
- sensor_threshold_emit_normal(sensor);
- }
- }
- //}
-}
-
diff --git a/includes/sensor_threshold.h b/includes/sensor_threshold.h
deleted file mode 100644
index b02c8ca..0000000
--- a/includes/sensor_threshold.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef __SENSOR_THRESHOLDS_H__
-#define __SENSOR_THRESHOLDS_H__
-
-#include <stdint.h>
-#include "interfaces/openbmc_intf.h"
-
-typedef enum { NOT_SET,NORMAL,LOWER_CRITICAL,LOWER_WARNING,UPPER_WARNING,UPPER_CRITICAL } threshold_states;
-
-gboolean get_threshold_state(SensorThreshold*,
- GDBusMethodInvocation*,gpointer);
-
-void check_thresholds(SensorThreshold*,GVariant*);
-
-
-#endif
diff --git a/ledctl/Makefile b/ledctl/Makefile
new file mode 100644
index 0000000..fa2b578
--- /dev/null
+++ b/ledctl/Makefile
@@ -0,0 +1,3 @@
+BINS=led_controller
+include ../sdbus.mk
+include ../rules.mk
diff --git a/objects/led_controller.c b/ledctl/led_controller.c
similarity index 100%
rename from objects/led_controller.c
rename to ledctl/led_controller.c
diff --git a/libopenbmc_intf/Makefile b/libopenbmc_intf/Makefile
new file mode 100644
index 0000000..9cd7be6
--- /dev/null
+++ b/libopenbmc_intf/Makefile
@@ -0,0 +1,20 @@
+PACKAGE_DEPS=gio-unix-2.0 glib-2.0
+INSTALLDEPS=install-lib
+CLEANDEPS=clean-lib
+DEFAULT_ALL=$(LIBOBMC)
+CFLAGS+=-iquote ../gdbus
+LIBOBMC=openbmc_intf
+
+$(LIBOBMC): %: %.o gpio.o
+ $(CC) -shared $(LDFLAGS) -Wl,-soname,lib$(LIBOBMC).so \
+ -o lib$@.so.1 $^ $(LDLIBS)
+
+install-lib:
+ @mkdir -p $(DESTDIR)$(libdir)
+ install lib$(LIBOBMC).so.1 $(DESTDIR)$(libdir)
+ ln -s lib$(LIBOBMC).so.1 $(DESTDIR)$(libdir)/lib$(LIBOBMC).so
+
+clean-lib:
+ rm -f lib$(LIBOBMC).so.1
+
+include ../rules.mk
diff --git a/includes/gpio.c b/libopenbmc_intf/gpio.c
old mode 100755
new mode 100644
similarity index 100%
rename from includes/gpio.c
rename to libopenbmc_intf/gpio.c
diff --git a/includes/gpio.h b/libopenbmc_intf/gpio.h
similarity index 100%
rename from includes/gpio.h
rename to libopenbmc_intf/gpio.h
diff --git a/includes/openbmc.h b/libopenbmc_intf/openbmc.h
similarity index 100%
rename from includes/openbmc.h
rename to libopenbmc_intf/openbmc.h
diff --git a/libopenbmc_intf/openbmc_intf.c b/libopenbmc_intf/openbmc_intf.c
new file mode 120000
index 0000000..3ac5de7
--- /dev/null
+++ b/libopenbmc_intf/openbmc_intf.c
@@ -0,0 +1 @@
+../gdbus/interfaces/openbmc_intf.c
\ No newline at end of file
diff --git a/libopenbmc_intf/openbmc_intf.h b/libopenbmc_intf/openbmc_intf.h
new file mode 120000
index 0000000..957c7b7
--- /dev/null
+++ b/libopenbmc_intf/openbmc_intf.h
@@ -0,0 +1 @@
+../gdbus/interfaces/openbmc_intf.h
\ No newline at end of file
diff --git a/objects/pflash/progress.o b/objects/pflash/progress.o
deleted file mode 100644
index 5153ecb..0000000
--- a/objects/pflash/progress.o
+++ /dev/null
Binary files differ
diff --git a/op-flasher/Makefile b/op-flasher/Makefile
new file mode 100644
index 0000000..80b9ccb
--- /dev/null
+++ b/op-flasher/Makefile
@@ -0,0 +1,14 @@
+BINS=flasher
+EXTRA_OBJS+=progress.o \
+ ast-sf-ctrl.o \
+ libflash.o \
+ libffs.o \
+ arm_io.o
+CFLAGS+=-Ipflash
+include ../gdbus.mk
+include ../rules.mk
+
+%.o: pflash/%.c
+ $(CC) -c -o $(CFLAGS) -fPIC -o $@ $<
+%.o: pflash/libflash/%.c
+ $(CC) -c -o $(CFLAGS) -fPIC -o $@ $<
diff --git a/objects/flasher_obj.c b/op-flasher/flasher_obj.c
similarity index 99%
rename from objects/flasher_obj.c
rename to op-flasher/flasher_obj.c
index 56ca61f..95892bd 100644
--- a/objects/flasher_obj.c
+++ b/op-flasher/flasher_obj.c
@@ -21,7 +21,7 @@
#include "ast.h"
#include "sfc-ctrl.h"
#include "interfaces/openbmc_intf.h"
-#include "includes/openbmc.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/objects/pflash/Makefile b/op-flasher/pflash/Makefile
similarity index 100%
rename from objects/pflash/Makefile
rename to op-flasher/pflash/Makefile
diff --git a/objects/pflash/TODO b/op-flasher/pflash/TODO
similarity index 100%
rename from objects/pflash/TODO
rename to op-flasher/pflash/TODO
diff --git a/objects/pflash/arm_io.c b/op-flasher/pflash/arm_io.c
similarity index 100%
rename from objects/pflash/arm_io.c
rename to op-flasher/pflash/arm_io.c
diff --git a/objects/pflash/ast-sf-ctrl.c b/op-flasher/pflash/ast-sf-ctrl.c
similarity index 100%
rename from objects/pflash/ast-sf-ctrl.c
rename to op-flasher/pflash/ast-sf-ctrl.c
diff --git a/objects/pflash/ast.h b/op-flasher/pflash/ast.h
similarity index 100%
rename from objects/pflash/ast.h
rename to op-flasher/pflash/ast.h
diff --git a/objects/pflash/ccan/Makefile.inc b/op-flasher/pflash/ccan/Makefile.inc
similarity index 100%
rename from objects/pflash/ccan/Makefile.inc
rename to op-flasher/pflash/ccan/Makefile.inc
diff --git a/objects/pflash/ccan/array_size/LICENSE b/op-flasher/pflash/ccan/array_size/LICENSE
similarity index 100%
rename from objects/pflash/ccan/array_size/LICENSE
rename to op-flasher/pflash/ccan/array_size/LICENSE
diff --git a/objects/pflash/ccan/array_size/_info b/op-flasher/pflash/ccan/array_size/_info
similarity index 100%
rename from objects/pflash/ccan/array_size/_info
rename to op-flasher/pflash/ccan/array_size/_info
diff --git a/objects/pflash/ccan/array_size/array_size.h b/op-flasher/pflash/ccan/array_size/array_size.h
similarity index 100%
rename from objects/pflash/ccan/array_size/array_size.h
rename to op-flasher/pflash/ccan/array_size/array_size.h
diff --git a/objects/pflash/ccan/array_size/test/compile_fail-function-param.c b/op-flasher/pflash/ccan/array_size/test/compile_fail-function-param.c
similarity index 100%
rename from objects/pflash/ccan/array_size/test/compile_fail-function-param.c
rename to op-flasher/pflash/ccan/array_size/test/compile_fail-function-param.c
diff --git a/objects/pflash/ccan/array_size/test/compile_fail.c b/op-flasher/pflash/ccan/array_size/test/compile_fail.c
similarity index 100%
rename from objects/pflash/ccan/array_size/test/compile_fail.c
rename to op-flasher/pflash/ccan/array_size/test/compile_fail.c
diff --git a/objects/pflash/ccan/array_size/test/run.c b/op-flasher/pflash/ccan/array_size/test/run.c
similarity index 100%
rename from objects/pflash/ccan/array_size/test/run.c
rename to op-flasher/pflash/ccan/array_size/test/run.c
diff --git a/objects/pflash/ccan/build_assert/LICENSE b/op-flasher/pflash/ccan/build_assert/LICENSE
similarity index 100%
rename from objects/pflash/ccan/build_assert/LICENSE
rename to op-flasher/pflash/ccan/build_assert/LICENSE
diff --git a/objects/pflash/ccan/build_assert/_info b/op-flasher/pflash/ccan/build_assert/_info
similarity index 100%
rename from objects/pflash/ccan/build_assert/_info
rename to op-flasher/pflash/ccan/build_assert/_info
diff --git a/objects/pflash/ccan/build_assert/build_assert.h b/op-flasher/pflash/ccan/build_assert/build_assert.h
similarity index 100%
rename from objects/pflash/ccan/build_assert/build_assert.h
rename to op-flasher/pflash/ccan/build_assert/build_assert.h
diff --git a/objects/pflash/ccan/build_assert/test/compile_fail-expr.c b/op-flasher/pflash/ccan/build_assert/test/compile_fail-expr.c
similarity index 100%
rename from objects/pflash/ccan/build_assert/test/compile_fail-expr.c
rename to op-flasher/pflash/ccan/build_assert/test/compile_fail-expr.c
diff --git a/objects/pflash/ccan/build_assert/test/compile_fail.c b/op-flasher/pflash/ccan/build_assert/test/compile_fail.c
similarity index 100%
rename from objects/pflash/ccan/build_assert/test/compile_fail.c
rename to op-flasher/pflash/ccan/build_assert/test/compile_fail.c
diff --git a/objects/pflash/ccan/build_assert/test/compile_ok.c b/op-flasher/pflash/ccan/build_assert/test/compile_ok.c
similarity index 100%
rename from objects/pflash/ccan/build_assert/test/compile_ok.c
rename to op-flasher/pflash/ccan/build_assert/test/compile_ok.c
diff --git a/objects/pflash/ccan/build_assert/test/run-BUILD_ASSERT_OR_ZERO.c b/op-flasher/pflash/ccan/build_assert/test/run-BUILD_ASSERT_OR_ZERO.c
similarity index 100%
rename from objects/pflash/ccan/build_assert/test/run-BUILD_ASSERT_OR_ZERO.c
rename to op-flasher/pflash/ccan/build_assert/test/run-BUILD_ASSERT_OR_ZERO.c
diff --git a/objects/pflash/ccan/built-in.o b/op-flasher/pflash/ccan/built-in.o
similarity index 100%
rename from objects/pflash/ccan/built-in.o
rename to op-flasher/pflash/ccan/built-in.o
Binary files differ
diff --git a/objects/pflash/ccan/check_type/LICENSE b/op-flasher/pflash/ccan/check_type/LICENSE
similarity index 100%
rename from objects/pflash/ccan/check_type/LICENSE
rename to op-flasher/pflash/ccan/check_type/LICENSE
diff --git a/objects/pflash/ccan/check_type/_info b/op-flasher/pflash/ccan/check_type/_info
similarity index 100%
rename from objects/pflash/ccan/check_type/_info
rename to op-flasher/pflash/ccan/check_type/_info
diff --git a/objects/pflash/ccan/check_type/check_type.h b/op-flasher/pflash/ccan/check_type/check_type.h
similarity index 100%
rename from objects/pflash/ccan/check_type/check_type.h
rename to op-flasher/pflash/ccan/check_type/check_type.h
diff --git a/objects/pflash/ccan/check_type/test/compile_fail-check_type.c b/op-flasher/pflash/ccan/check_type/test/compile_fail-check_type.c
similarity index 100%
rename from objects/pflash/ccan/check_type/test/compile_fail-check_type.c
rename to op-flasher/pflash/ccan/check_type/test/compile_fail-check_type.c
diff --git a/objects/pflash/ccan/check_type/test/compile_fail-check_type_unsigned.c b/op-flasher/pflash/ccan/check_type/test/compile_fail-check_type_unsigned.c
similarity index 100%
rename from objects/pflash/ccan/check_type/test/compile_fail-check_type_unsigned.c
rename to op-flasher/pflash/ccan/check_type/test/compile_fail-check_type_unsigned.c
diff --git a/objects/pflash/ccan/check_type/test/compile_fail-check_types_match.c b/op-flasher/pflash/ccan/check_type/test/compile_fail-check_types_match.c
similarity index 100%
rename from objects/pflash/ccan/check_type/test/compile_fail-check_types_match.c
rename to op-flasher/pflash/ccan/check_type/test/compile_fail-check_types_match.c
diff --git a/objects/pflash/ccan/check_type/test/run.c b/op-flasher/pflash/ccan/check_type/test/run.c
similarity index 100%
rename from objects/pflash/ccan/check_type/test/run.c
rename to op-flasher/pflash/ccan/check_type/test/run.c
diff --git a/objects/pflash/ccan/container_of/LICENSE b/op-flasher/pflash/ccan/container_of/LICENSE
similarity index 100%
rename from objects/pflash/ccan/container_of/LICENSE
rename to op-flasher/pflash/ccan/container_of/LICENSE
diff --git a/objects/pflash/ccan/container_of/_info b/op-flasher/pflash/ccan/container_of/_info
similarity index 100%
rename from objects/pflash/ccan/container_of/_info
rename to op-flasher/pflash/ccan/container_of/_info
diff --git a/objects/pflash/ccan/container_of/container_of.h b/op-flasher/pflash/ccan/container_of/container_of.h
similarity index 100%
rename from objects/pflash/ccan/container_of/container_of.h
rename to op-flasher/pflash/ccan/container_of/container_of.h
diff --git a/objects/pflash/ccan/container_of/test/compile_fail-bad-type.c b/op-flasher/pflash/ccan/container_of/test/compile_fail-bad-type.c
similarity index 100%
rename from objects/pflash/ccan/container_of/test/compile_fail-bad-type.c
rename to op-flasher/pflash/ccan/container_of/test/compile_fail-bad-type.c
diff --git a/objects/pflash/ccan/container_of/test/compile_fail-types.c b/op-flasher/pflash/ccan/container_of/test/compile_fail-types.c
similarity index 100%
rename from objects/pflash/ccan/container_of/test/compile_fail-types.c
rename to op-flasher/pflash/ccan/container_of/test/compile_fail-types.c
diff --git a/objects/pflash/ccan/container_of/test/compile_fail-var-types.c b/op-flasher/pflash/ccan/container_of/test/compile_fail-var-types.c
similarity index 100%
rename from objects/pflash/ccan/container_of/test/compile_fail-var-types.c
rename to op-flasher/pflash/ccan/container_of/test/compile_fail-var-types.c
diff --git a/objects/pflash/ccan/container_of/test/run.c b/op-flasher/pflash/ccan/container_of/test/run.c
similarity index 100%
rename from objects/pflash/ccan/container_of/test/run.c
rename to op-flasher/pflash/ccan/container_of/test/run.c
diff --git a/objects/pflash/ccan/endian/LICENSE b/op-flasher/pflash/ccan/endian/LICENSE
similarity index 100%
rename from objects/pflash/ccan/endian/LICENSE
rename to op-flasher/pflash/ccan/endian/LICENSE
diff --git a/objects/pflash/ccan/endian/_info b/op-flasher/pflash/ccan/endian/_info
similarity index 100%
rename from objects/pflash/ccan/endian/_info
rename to op-flasher/pflash/ccan/endian/_info
diff --git a/objects/pflash/ccan/endian/endian.h b/op-flasher/pflash/ccan/endian/endian.h
similarity index 100%
rename from objects/pflash/ccan/endian/endian.h
rename to op-flasher/pflash/ccan/endian/endian.h
diff --git a/objects/pflash/ccan/endian/test/compile_ok-constant.c b/op-flasher/pflash/ccan/endian/test/compile_ok-constant.c
similarity index 100%
rename from objects/pflash/ccan/endian/test/compile_ok-constant.c
rename to op-flasher/pflash/ccan/endian/test/compile_ok-constant.c
diff --git a/objects/pflash/ccan/endian/test/run.c b/op-flasher/pflash/ccan/endian/test/run.c
similarity index 100%
rename from objects/pflash/ccan/endian/test/run.c
rename to op-flasher/pflash/ccan/endian/test/run.c
diff --git a/objects/pflash/config.h b/op-flasher/pflash/config.h
similarity index 100%
rename from objects/pflash/config.h
rename to op-flasher/pflash/config.h
diff --git a/objects/pflash/get_arch.sh b/op-flasher/pflash/get_arch.sh
similarity index 100%
rename from objects/pflash/get_arch.sh
rename to op-flasher/pflash/get_arch.sh
diff --git a/objects/pflash/io.h b/op-flasher/pflash/io.h
similarity index 100%
rename from objects/pflash/io.h
rename to op-flasher/pflash/io.h
diff --git a/objects/pflash/libflash/ffs.h b/op-flasher/pflash/libflash/ffs.h
similarity index 100%
rename from objects/pflash/libflash/ffs.h
rename to op-flasher/pflash/libflash/ffs.h
diff --git a/objects/pflash/libflash/libffs.c b/op-flasher/pflash/libflash/libffs.c
similarity index 100%
rename from objects/pflash/libflash/libffs.c
rename to op-flasher/pflash/libflash/libffs.c
diff --git a/objects/pflash/libflash/libffs.h b/op-flasher/pflash/libflash/libffs.h
similarity index 100%
rename from objects/pflash/libflash/libffs.h
rename to op-flasher/pflash/libflash/libffs.h
diff --git a/objects/pflash/libflash/libflash-priv.h b/op-flasher/pflash/libflash/libflash-priv.h
similarity index 100%
rename from objects/pflash/libflash/libflash-priv.h
rename to op-flasher/pflash/libflash/libflash-priv.h
diff --git a/objects/pflash/libflash/libflash.c b/op-flasher/pflash/libflash/libflash.c
similarity index 100%
rename from objects/pflash/libflash/libflash.c
rename to op-flasher/pflash/libflash/libflash.c
diff --git a/objects/pflash/libflash/libflash.h b/op-flasher/pflash/libflash/libflash.h
similarity index 100%
rename from objects/pflash/libflash/libflash.h
rename to op-flasher/pflash/libflash/libflash.h
diff --git a/objects/pflash/libflash/test/Makefile b/op-flasher/pflash/libflash/test/Makefile
similarity index 100%
rename from objects/pflash/libflash/test/Makefile
rename to op-flasher/pflash/libflash/test/Makefile
diff --git a/objects/pflash/libflash/test/test-flash.c b/op-flasher/pflash/libflash/test/test-flash.c
similarity index 100%
rename from objects/pflash/libflash/test/test-flash.c
rename to op-flasher/pflash/libflash/test/test-flash.c
diff --git a/objects/pflash/pflash.c b/op-flasher/pflash/pflash.c
similarity index 100%
rename from objects/pflash/pflash.c
rename to op-flasher/pflash/pflash.c
diff --git a/objects/pflash/powerpc_io.c b/op-flasher/pflash/powerpc_io.c
similarity index 100%
rename from objects/pflash/powerpc_io.c
rename to op-flasher/pflash/powerpc_io.c
diff --git a/objects/pflash/progress.c b/op-flasher/pflash/progress.c
similarity index 100%
rename from objects/pflash/progress.c
rename to op-flasher/pflash/progress.c
diff --git a/objects/pflash/progress.h b/op-flasher/pflash/progress.h
similarity index 100%
rename from objects/pflash/progress.h
rename to op-flasher/pflash/progress.h
diff --git a/objects/pflash/sfc-ctrl.c b/op-flasher/pflash/sfc-ctrl.c
similarity index 100%
rename from objects/pflash/sfc-ctrl.c
rename to op-flasher/pflash/sfc-ctrl.c
diff --git a/objects/pflash/sfc-ctrl.h b/op-flasher/pflash/sfc-ctrl.h
similarity index 100%
rename from objects/pflash/sfc-ctrl.h
rename to op-flasher/pflash/sfc-ctrl.h
diff --git a/op-hostctl/Makefile b/op-hostctl/Makefile
new file mode 100644
index 0000000..99f63dc
--- /dev/null
+++ b/op-hostctl/Makefile
@@ -0,0 +1,3 @@
+BINS=control_host
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/control_host_obj.c b/op-hostctl/control_host_obj.c
old mode 100755
new mode 100644
similarity index 100%
rename from objects/control_host_obj.c
rename to op-hostctl/control_host_obj.c
diff --git a/op-pwrctl/Makefile b/op-pwrctl/Makefile
new file mode 100644
index 0000000..b1188ae
--- /dev/null
+++ b/op-pwrctl/Makefile
@@ -0,0 +1,3 @@
+BINS=power_control
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/power_control_obj.c b/op-pwrctl/power_control_obj.c
similarity index 100%
rename from objects/power_control_obj.c
rename to op-pwrctl/power_control_obj.c
diff --git a/pciedetect/Makefile b/pciedetect/Makefile
new file mode 100644
index 0000000..21aaadc
--- /dev/null
+++ b/pciedetect/Makefile
@@ -0,0 +1,3 @@
+BINS=pcie_slot_present
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/pcie_slot_present_obj.c b/pciedetect/pcie_slot_present_obj.c
similarity index 100%
rename from objects/pcie_slot_present_obj.c
rename to pciedetect/pcie_slot_present_obj.c
diff --git a/pwrbutton/Makefile b/pwrbutton/Makefile
new file mode 100644
index 0000000..a92236f
--- /dev/null
+++ b/pwrbutton/Makefile
@@ -0,0 +1,3 @@
+BINS=button_power
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/button_power_obj.c b/pwrbutton/button_power_obj.c
similarity index 100%
rename from objects/button_power_obj.c
rename to pwrbutton/button_power_obj.c
diff --git a/py.mk b/py.mk
new file mode 100644
index 0000000..9669fce
--- /dev/null
+++ b/py.mk
@@ -0,0 +1,9 @@
+PYTHON?=python
+all:
+ $(PYTHON) setup.py build
+
+clean:
+ rm -rf build
+
+install: all
+ $(PYTHON) setup.py install --root=$(DESTDIR) --prefix=$(PREFIX)
diff --git a/pychassisctl/Makefile b/pychassisctl/Makefile
new file mode 120000
index 0000000..76a90fc
--- /dev/null
+++ b/pychassisctl/Makefile
@@ -0,0 +1 @@
+../Makefile.python
\ No newline at end of file
diff --git a/bin/chassis_control.py b/pychassisctl/chassis_control.py
old mode 100755
new mode 100644
similarity index 100%
rename from bin/chassis_control.py
rename to pychassisctl/chassis_control.py
diff --git a/pychassisctl/setup.cfg b/pychassisctl/setup.cfg
new file mode 120000
index 0000000..29939b5
--- /dev/null
+++ b/pychassisctl/setup.cfg
@@ -0,0 +1 @@
+../setup.cfg
\ No newline at end of file
diff --git a/pychassisctl/setup.py b/pychassisctl/setup.py
new file mode 100644
index 0000000..b86c7e8
--- /dev/null
+++ b/pychassisctl/setup.py
@@ -0,0 +1,6 @@
+from distutils.core import setup
+
+setup(name='pychassisctl',
+ version='1.0',
+ scripts=['chassis_control.py'],
+ )
diff --git a/pydownloadmgr/Makefile b/pydownloadmgr/Makefile
new file mode 120000
index 0000000..76a90fc
--- /dev/null
+++ b/pydownloadmgr/Makefile
@@ -0,0 +1 @@
+../Makefile.python
\ No newline at end of file
diff --git a/bin/download_manager.py b/pydownloadmgr/download_manager.py
old mode 100755
new mode 100644
similarity index 94%
rename from bin/download_manager.py
rename to pydownloadmgr/download_manager.py
index ba502da..9dd6c2d
--- a/bin/download_manager.py
+++ b/pydownloadmgr/download_manager.py
@@ -7,11 +7,7 @@
import dbus.mainloop.glib
import subprocess
from obmc.dbuslib.bindings import get_dbus
-
-if (len(sys.argv) < 2):
- print "Usage: download_manager.py [system name]"
- exit(1)
-System = __import__(sys.argv[1])
+import obmc_system_config as System
DBUS_NAME = 'org.openbmc.managers.Download'
diff --git a/pydownloadmgr/setup.cfg b/pydownloadmgr/setup.cfg
new file mode 120000
index 0000000..29939b5
--- /dev/null
+++ b/pydownloadmgr/setup.cfg
@@ -0,0 +1 @@
+../setup.cfg
\ No newline at end of file
diff --git a/pydownloadmgr/setup.py b/pydownloadmgr/setup.py
new file mode 100644
index 0000000..35c8b6d
--- /dev/null
+++ b/pydownloadmgr/setup.py
@@ -0,0 +1,6 @@
+from distutils.core import setup
+
+setup(name='pydownloadmgr',
+ version='1.0',
+ scripts=['download_manager.py'],
+ )
diff --git a/pyfanctl/Makefile b/pyfanctl/Makefile
new file mode 120000
index 0000000..76a90fc
--- /dev/null
+++ b/pyfanctl/Makefile
@@ -0,0 +1 @@
+../Makefile.python
\ No newline at end of file
diff --git a/bin/fan_control.py b/pyfanctl/fan_control.py
old mode 100755
new mode 100644
similarity index 100%
rename from bin/fan_control.py
rename to pyfanctl/fan_control.py
diff --git a/pyfanctl/setup.cfg b/pyfanctl/setup.cfg
new file mode 120000
index 0000000..29939b5
--- /dev/null
+++ b/pyfanctl/setup.cfg
@@ -0,0 +1 @@
+../setup.cfg
\ No newline at end of file
diff --git a/pyfanctl/setup.py b/pyfanctl/setup.py
new file mode 100644
index 0000000..655808d
--- /dev/null
+++ b/pyfanctl/setup.py
@@ -0,0 +1,6 @@
+from distutils.core import setup
+
+setup(name='pyfanctl',
+ version='1.0',
+ scripts=['fan_control.py'],
+ )
diff --git a/pyflashbmc/Makefile b/pyflashbmc/Makefile
new file mode 120000
index 0000000..76a90fc
--- /dev/null
+++ b/pyflashbmc/Makefile
@@ -0,0 +1 @@
+../Makefile.python
\ No newline at end of file
diff --git a/bin/bmc_update.py b/pyflashbmc/bmc_update.py
old mode 100755
new mode 100644
similarity index 100%
rename from bin/bmc_update.py
rename to pyflashbmc/bmc_update.py
diff --git a/pyflashbmc/setup.cfg b/pyflashbmc/setup.cfg
new file mode 120000
index 0000000..29939b5
--- /dev/null
+++ b/pyflashbmc/setup.cfg
@@ -0,0 +1 @@
+../setup.cfg
\ No newline at end of file
diff --git a/pyflashbmc/setup.py b/pyflashbmc/setup.py
new file mode 100644
index 0000000..ed86cbb
--- /dev/null
+++ b/pyflashbmc/setup.py
@@ -0,0 +1,6 @@
+from distutils.core import setup
+
+setup(name='pyflashbmc',
+ version='1.0',
+ scripts=['bmc_update.py'],
+ )
diff --git a/pyhwmon/Makefile b/pyhwmon/Makefile
new file mode 120000
index 0000000..76a90fc
--- /dev/null
+++ b/pyhwmon/Makefile
@@ -0,0 +1 @@
+../Makefile.python
\ No newline at end of file
diff --git a/bin/hwmon.py b/pyhwmon/hwmon.py
old mode 100755
new mode 100644
similarity index 97%
rename from bin/hwmon.py
rename to pyhwmon/hwmon.py
index 9f4b1d9..a91b761
--- a/bin/hwmon.py
+++ b/pyhwmon/hwmon.py
@@ -13,12 +13,7 @@
from obmc.sensors import SensorValue as SensorValue
from obmc.sensors import HwmonSensor as HwmonSensor
from obmc.sensors import SensorThresholds as SensorThresholds
-
-if (len(sys.argv) < 2):
- print "Usage: sensors_hwmon.py [system name]"
- exit(1)
-
-System = __import__(sys.argv[1])
+import obmc_system_config as System
SENSOR_BUS = 'org.openbmc.Sensors'
SENSOR_PATH = '/org/openbmc/sensors'
diff --git a/pyhwmon/setup.cfg b/pyhwmon/setup.cfg
new file mode 120000
index 0000000..29939b5
--- /dev/null
+++ b/pyhwmon/setup.cfg
@@ -0,0 +1 @@
+../setup.cfg
\ No newline at end of file
diff --git a/pyhwmon/setup.py b/pyhwmon/setup.py
new file mode 100644
index 0000000..41b3b9a
--- /dev/null
+++ b/pyhwmon/setup.py
@@ -0,0 +1,6 @@
+from distutils.core import setup
+
+setup(name='pyhwmon',
+ version='1.0',
+ scripts=['hwmon.py'],
+ )
diff --git a/pyinventorymgr/Makefile b/pyinventorymgr/Makefile
new file mode 120000
index 0000000..76a90fc
--- /dev/null
+++ b/pyinventorymgr/Makefile
@@ -0,0 +1 @@
+../Makefile.python
\ No newline at end of file
diff --git a/bin/inventory_items.py b/pyinventorymgr/inventory_items.py
old mode 100755
new mode 100644
similarity index 94%
rename from bin/inventory_items.py
rename to pyinventorymgr/inventory_items.py
index 5e53293..772fb3e
--- a/bin/inventory_items.py
+++ b/pyinventorymgr/inventory_items.py
@@ -10,12 +10,7 @@
import json
import obmc.dbuslib.propertycacher as PropertyCacher
from obmc.dbuslib.bindings import get_dbus, DbusProperties, DbusObjectManager
-
-if (len(sys.argv) < 2):
- print "Usage: inventory_items.py [system name]"
- exit(1)
-System = __import__(sys.argv[1])
-
+import obmc_system_config as System
INTF_NAME = 'org.openbmc.InventoryItem'
DBUS_NAME = 'org.openbmc.Inventory'
diff --git a/pyinventorymgr/setup.cfg b/pyinventorymgr/setup.cfg
new file mode 120000
index 0000000..29939b5
--- /dev/null
+++ b/pyinventorymgr/setup.cfg
@@ -0,0 +1 @@
+../setup.cfg
\ No newline at end of file
diff --git a/pyinventorymgr/setup.py b/pyinventorymgr/setup.py
new file mode 100644
index 0000000..851d961
--- /dev/null
+++ b/pyinventorymgr/setup.py
@@ -0,0 +1,6 @@
+from distutils.core import setup
+
+setup(name='pyinventorymgr',
+ version='1.0',
+ scripts=['inventory_items.py'],
+ )
diff --git a/pyipmitest/Makefile b/pyipmitest/Makefile
new file mode 120000
index 0000000..76a90fc
--- /dev/null
+++ b/pyipmitest/Makefile
@@ -0,0 +1 @@
+../Makefile.python
\ No newline at end of file
diff --git a/bin/ipmi_debug.py b/pyipmitest/ipmi_debug.py
old mode 100755
new mode 100644
similarity index 100%
rename from bin/ipmi_debug.py
rename to pyipmitest/ipmi_debug.py
diff --git a/pyipmitest/setup.cfg b/pyipmitest/setup.cfg
new file mode 120000
index 0000000..29939b5
--- /dev/null
+++ b/pyipmitest/setup.cfg
@@ -0,0 +1 @@
+../setup.cfg
\ No newline at end of file
diff --git a/pyipmitest/setup.py b/pyipmitest/setup.py
new file mode 100644
index 0000000..37957b8
--- /dev/null
+++ b/pyipmitest/setup.py
@@ -0,0 +1,6 @@
+from distutils.core import setup
+
+setup(name='pyipmitest',
+ version='1.0',
+ scripts=['ipmi_debug.py'],
+ )
diff --git a/pysensormgr/Makefile b/pysensormgr/Makefile
new file mode 120000
index 0000000..76a90fc
--- /dev/null
+++ b/pysensormgr/Makefile
@@ -0,0 +1 @@
+../Makefile.python
\ No newline at end of file
diff --git a/bin/sensor_manager2.py b/pysensormgr/sensor_manager2.py
old mode 100755
new mode 100644
similarity index 97%
rename from bin/sensor_manager2.py
rename to pysensormgr/sensor_manager2.py
index fa3638a..d8fa013
--- a/bin/sensor_manager2.py
+++ b/pysensormgr/sensor_manager2.py
@@ -8,8 +8,7 @@
import dbus.mainloop.glib
import obmc.sensors
from obmc.dbuslib.bindings import DbusProperties, DbusObjectManager, get_dbus
-
-System = __import__(sys.argv[1])
+import obmc_system_config as System
DBUS_NAME = 'org.openbmc.Sensors'
OBJ_PATH = '/org/openbmc/sensors'
diff --git a/pysensormgr/setup.cfg b/pysensormgr/setup.cfg
new file mode 120000
index 0000000..29939b5
--- /dev/null
+++ b/pysensormgr/setup.cfg
@@ -0,0 +1 @@
+../setup.cfg
\ No newline at end of file
diff --git a/pysensormgr/setup.py b/pysensormgr/setup.py
new file mode 100644
index 0000000..7944841
--- /dev/null
+++ b/pysensormgr/setup.py
@@ -0,0 +1,6 @@
+from distutils.core import setup
+
+setup(name='pysensormgr',
+ version='1.0',
+ scripts=['sensor_manager2.py'],
+ )
diff --git a/pystatemgr/Makefile b/pystatemgr/Makefile
new file mode 120000
index 0000000..76a90fc
--- /dev/null
+++ b/pystatemgr/Makefile
@@ -0,0 +1 @@
+../Makefile.python
\ No newline at end of file
diff --git a/bin/discover_system_state.py b/pystatemgr/discover_system_state.py
old mode 100755
new mode 100644
similarity index 100%
rename from bin/discover_system_state.py
rename to pystatemgr/discover_system_state.py
diff --git a/bin/goto_system_state.py b/pystatemgr/goto_system_state.py
similarity index 100%
rename from bin/goto_system_state.py
rename to pystatemgr/goto_system_state.py
diff --git a/pystatemgr/setup.cfg b/pystatemgr/setup.cfg
new file mode 120000
index 0000000..29939b5
--- /dev/null
+++ b/pystatemgr/setup.cfg
@@ -0,0 +1 @@
+../setup.cfg
\ No newline at end of file
diff --git a/pystatemgr/setup.py b/pystatemgr/setup.py
new file mode 100644
index 0000000..86c7471
--- /dev/null
+++ b/pystatemgr/setup.py
@@ -0,0 +1,6 @@
+from distutils.core import setup
+
+setup(name='pystatemgr',
+ version='1.0',
+ scripts=['discover_system_state.py', 'goto_system_state.py'],
+ )
diff --git a/pysystemmgr/Makefile b/pysystemmgr/Makefile
new file mode 120000
index 0000000..76a90fc
--- /dev/null
+++ b/pysystemmgr/Makefile
@@ -0,0 +1 @@
+../Makefile.python
\ No newline at end of file
diff --git a/pysystemmgr/setup.cfg b/pysystemmgr/setup.cfg
new file mode 120000
index 0000000..29939b5
--- /dev/null
+++ b/pysystemmgr/setup.cfg
@@ -0,0 +1 @@
+../setup.cfg
\ No newline at end of file
diff --git a/pysystemmgr/setup.py b/pysystemmgr/setup.py
new file mode 100644
index 0000000..4207620
--- /dev/null
+++ b/pysystemmgr/setup.py
@@ -0,0 +1,6 @@
+from distutils.core import setup
+
+setup(name='pysystemmgr',
+ version='1.0',
+ scripts=['system_manager.py'],
+ )
diff --git a/bin/system_manager.py b/pysystemmgr/system_manager.py
old mode 100755
new mode 100644
similarity index 98%
rename from bin/system_manager.py
rename to pysystemmgr/system_manager.py
index 754700b..93ba603
--- a/bin/system_manager.py
+++ b/pysystemmgr/system_manager.py
@@ -11,12 +11,7 @@
import obmc.dbuslib.propertycacher as PropertyCacher
from obmc.dbuslib.bindings import DbusProperties, DbusObjectManager, get_dbus
import obmc.enums
-
-if (len(sys.argv) < 2):
- print "Usage: system_manager.py [system name]"
- exit(1)
-
-System = __import__(sys.argv[1])
+import obmc_system_config as System
DBUS_NAME = 'org.openbmc.managers.System'
OBJ_NAME = '/org/openbmc/managers/System'
diff --git a/pytools/Makefile b/pytools/Makefile
new file mode 120000
index 0000000..76a90fc
--- /dev/null
+++ b/pytools/Makefile
@@ -0,0 +1 @@
+../Makefile.python
\ No newline at end of file
diff --git a/bin/gpioutil b/pytools/gpioutil
old mode 100755
new mode 100644
similarity index 88%
rename from bin/gpioutil
rename to pytools/gpioutil
index ab44b4d..b6ec5ea
--- a/bin/gpioutil
+++ b/pytools/gpioutil
@@ -3,25 +3,22 @@
import sys
import os
import getopt
+import obmc_system_config as System
def printUsage():
print '\nUsage:'
- print 'gpioutil SYSTEM_NAME -n GPIO_NAME [-v value]'
- print 'gpioutil SYSTEM_NAME -i GPIO_NUM -d <DIRECTION = in,out,falling,rising,both> [-v value]'
- print 'gpioutil SYSTEM_NAME -p PIN_NAME -d <DIRECTION = in,out,falling,rising,both> [-v value]'
- print 'gpioutil SYSTEM_NAME -l PIN_NAME (lookup pin name only)'
+ print 'gpioutil -n GPIO_NAME [-v value]'
+ print 'gpioutil -i GPIO_NUM -d <DIRECTION = in,out,falling,rising,both> [-v value]'
+ print 'gpioutil -p PIN_NAME -d <DIRECTION = in,out,falling,rising,both> [-v value]'
+ print 'gpioutil -l PIN_NAME (lookup pin name only)'
exit(1)
-if (len(sys.argv) < 3):
+if (len(sys.argv) < 2):
printUsage()
-sys.argv.pop(0)
-libr = sys.argv.pop(0)
-System = __import__(libr)
-
GPIO_SYSFS = '/sys/class/gpio/'
class Gpio:
diff --git a/bin/obmcutil b/pytools/obmcutil
old mode 100755
new mode 100644
similarity index 100%
rename from bin/obmcutil
rename to pytools/obmcutil
diff --git a/pytools/setup.cfg b/pytools/setup.cfg
new file mode 120000
index 0000000..29939b5
--- /dev/null
+++ b/pytools/setup.cfg
@@ -0,0 +1 @@
+../setup.cfg
\ No newline at end of file
diff --git a/pytools/setup.py b/pytools/setup.py
new file mode 100644
index 0000000..2736366
--- /dev/null
+++ b/pytools/setup.py
@@ -0,0 +1,6 @@
+from distutils.core import setup
+
+setup(name='pytools',
+ version='1.0',
+ scripts=['obmcutil', 'gpioutil'],
+ )
diff --git a/rstbutton/Makefile b/rstbutton/Makefile
new file mode 100644
index 0000000..906b099
--- /dev/null
+++ b/rstbutton/Makefile
@@ -0,0 +1,3 @@
+BINS=button_reset
+include ../gdbus.mk
+include ../rules.mk
diff --git a/objects/button_reset_obj.c b/rstbutton/button_reset_obj.c
similarity index 100%
rename from objects/button_reset_obj.c
rename to rstbutton/button_reset_obj.c
diff --git a/rules.mk b/rules.mk
new file mode 100644
index 0000000..9cad8cf
--- /dev/null
+++ b/rules.mk
@@ -0,0 +1,31 @@
+TOP := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
+
+.DEFAULT_GOAL := all
+sbindir=/usr/sbin
+libdir=/usr/lib
+
+LDLIBS+=$(shell pkg-config --libs $(PACKAGE_DEPS))
+CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) -Werror
+
+INSTALLDEPS?=install-bins
+BIN_SUFFIX?=.exe
+DEFAULT_ALL?=$(BINS)
+
+all: $(DEFAULT_ALL)
+
+%.o: %.c
+ $(CC) -c $(CFLAGS) -fPIC -o $@ $<
+
+$(BINS): %: %.o $(EXTRA_OBJS)
+ $(CC) $(LDFLAGS) -o $@$(BIN_SUFFIX) $^ $(LDLIBS)
+
+install-bins:
+ @mkdir -p $(DESTDIR)$(sbindir)
+ @for b in $(BINS); do \
+ install $$b$(BIN_SUFFIX) $(DESTDIR)$(sbindir) || exit 1; \
+ done
+
+install: all $(INSTALLDEPS)
+
+clean: $(CLEANDEPS)
+ rm -rf *.o $(BINS:=$(BIN_SUFFIX))
diff --git a/sdbus.mk b/sdbus.mk
new file mode 100644
index 0000000..67ad125
--- /dev/null
+++ b/sdbus.mk
@@ -0,0 +1 @@
+PACKAGE_DEPS=libsystemd
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..ed3bf6e
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,2 @@
+[install]
+install_scripts=/usr/sbin